fix(ai): loosen serialization of blocks in columns (#2716)#2718
fix(ai): loosen serialization of blocks in columns (#2716)#2718nperez0111 merged 1 commit intomainfrom
Conversation
xl-ai's flattenBlocks strips children before serializing each block to HTML, which made columnList/column nodes hit createChecked with empty content and throw "Invalid content for node columnList: <>". blockToNode now uses Node.create for the bnBlock branch; insertBlocks / replaceBlocks / updateBlock validate via node.check() before mutating the doc.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis pull request refactors block validation from eager to deferred validation by changing ChangesBlock Validation Refactoring
Multi-Column Support in xl-ai
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
Fixes #2716.
Summary
Using AI inside a
column(within acolumnList) crashed withUnexpected Error calling LLM RangeError: Invalid content for node columnList: <>.Rationale
xl-ai'sflattenBlocksstrips children from every block before piping each one througheditor.blocksToHTMLLossyfor the LLM.columnList(schema:column column+) andcolumn(schema:blockContainer+) then hitcreateCheckedinblockToNodewith empty content and threw.Changes
blockToNode:bnBlockbranch now usesNode.create(lenient) so partial container blocks can flow through HTML serialization.insertBlocks/replaceBlocks/updateBlock: each callsnode.check()afterblockToNode, so doc-mutating callers still reject invalid structures at the right boundary.@blocknote/xl-multi-columnas a devDep ofxl-aiplus a vite alias, so the regression test exercises the real schema.Testing
packages/xl-ai/src/api/formats/html-blocks/columnContainerDocumentState.test.tsreproduces the issue's flow throughhtmlBlockLLMFormat.defaultDocumentStateBuilder; fails onmain, passes here.core(422),xl-multi-column(62) andxl-ai(225) suites all green; the existingInsert empty column listetc. tests still throw, now vianode.check().Summary by CodeRabbit
Bug Fixes
Tests